package com.qdlc.p2p.biz.log.score.convert;

import com.qdlc.p2p.biz.log.score.BaseScoreConvertLog;
import com.qdlc.p2p.common.constant.ScoreTemplateConstant;
import com.qdlc.p2p.common.exception.ScoreException;

/**
 * 积分兑换VIP成功
 */
public class ScoreConvertVipSuccessLog extends BaseScoreConvertLog {

	private static final long serialVersionUID = 1L;
	
	private String logTemplateNid = ScoreTemplateConstant.SCORE_CONVERT_VIP_VERIFY_SUCCESS;
	
	public ScoreConvertVipSuccessLog() {
		super();
	}

	public ScoreConvertVipSuccessLog(long userId, int score) {
		super(userId, score, ScoreTemplateConstant.SCORE_CONVERT_VIP);
		this.setLogTemplateNid(logTemplateNid);
	}

	@Override
	public void modifyScore() {
		Boolean result = scoreDao.updateScore(this.getUser().getUserId(), 0, this.getScore(), 0, -this.getScore());
		if(!result){
			throw new ScoreException("更新用户积分失败！", 1);
		}
	}
	
}
